
/*
信息采集  从服务器端拷贝数据到应急调查设备
* 目标IP、目标端口、目标数据库名称、目标数据库用户名、目标数据库密码
*/
function getDbinfoFromServer(){
	var region =$("#sheng").val();
	if($("#xian").val()!="-1"){
		region = $("#xian").val();
	}else if($("#shi").val()!="-1"){
		region = $("#shi").val();
	}
	var ip = $("#targetIp").val();
	var port = $("#targetPort").val();
	var targetDbName = $("#targetDbName").val();
	var targetDbUsername = $("#targetDbUsername").val();
	var targetDbPassword = $("#targetDbPassword").val();
	var url = "YJDCXXCJGetInfoFromServer.shtml";
	var data = "";
	var tblList = "";
	var checkList = $("#tblList input:checked[type=checkbox]");
	for(var i=0;i<checkList.length;i++){
		tblList +=checkList[i].value+",";
	}
	tblList = tblList.substring(0,tblList.length-1);
	var dataObj = {
		"dBService":ip,
		"dBPort":port,
		"dBName":targetDbName,
		"userName":targetDbUsername,
		"passWord":targetDbPassword
	}
	data = JSON.stringify(dataObj);
	$("#loading").css("display","");
	$(".resStat").html("");
	$.post(url,{"dbinfo":data,"tblList":tblList,"region":region},cbGetDbinfoFromServer);
}
function cbGetDbinfoFromServer(response){
	$("#loading").css("display","none");
	var resStr = response.jsonResult;
	var resArr = resStr.split(",");
	var resStatList = $(".resStat");
	for(var i=0;i<resStatList.length;i++){
		resStatList[i].innerHTML = resArr[i]=="true"?"<font color='green'>拷贝成功</font>":"<font color='red'>拷贝失败</font>";
	}
}


//////////////////////////////王少波，对快报上传业务的函数群////////////////////////////
//initFileInput
function initFileInput(){
	$("#kbFile").change(function(){
		var file = $("#kbFile").val();
		var arr = file.split("\\");
		var fileName = arr[arr.length-1];
		var flag = checkFileName(fileName);
		if(!flag){
			alert("您选择的文件不合法!");
			$("#kbFile").val("");
			return;
		}
		$("#kbFileName").val(fileName);
	});
}


//判断名字是否符合要求
function checkFileName(fileName){
	var arr = fileName.split(".");
	var fileClass = arr[1];
	if(fileClass!="doc"&&fileClass!="docx"){
		return false;
	}
	var fileNameStr = arr[0];
	var tybh = fileNameStr.split("-")[0];
	var time = fileNameStr.split("-")[2];
	var leixing = fileNameStr.split("-")[3];
	if(tybh.length!=12){
		return false;
	}
	if(time.length!=14){
		return false;
	}
	if(leixing!="02"){
		return false;
	}
	return true;
}

//点击提交按钮
function submitClickFunc(){
	var fileName = $("#kbFileName").val();
	if(fileName==""){
		alert("必须上传报告！");
		return;
	}
	//想国土主干网提交表单
	var url = "insertKb.shtml";
	$("#yjdckbForm").attr("action",url+"?fileName="+fileName);
	$("#yjdckbForm").submit(function () {
		// 提交表单
		$(this).ajaxSubmit();
		// 为了防止普通浏览器进行表单提交和产生页面导航（防止页面刷新？）返回false
		return false;
	});
	$("#yjdckbForm").ajaxSubmit(function (res) {
		debugger;
		if(res.indexOf("true")>-1){
			alert("上传成功!");
		}else{
			alert("上传失败!");
		}
	});
}